﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FlexiCommerce.Localization;
using FlexiCommerce.Collections;
using N2.Engine.Globalization;
using FlexiCommerce.Components;

namespace FlexiCommerce.Web.Addons.FC.Components
{
    public class LocalizationManager : ILocalizationManager
    {

        public LocalizationManager()
        {
            this.innerLocalizationManager = new FlexiCommerce.Localization.LocalizationManager();
        }

        private ILocalizationManager innerLocalizationManager;

        #region ILocalizationManager Members

        public bool UseSystemLanguagePersistence
        {
            get { return false; }
        }

        public IEnumerable<global::FlexiCommerce.Components.Culture> ConfiguredCultures()
        {
            foreach (ILanguage language in N2.Context.Current.Resolve<ILanguageGateway>().GetAvailableLanguages())
            {
                yield return new Culture(language.LanguageCode);
            }
        }

        public string GetResource(string resourceName)
        {
            return innerLocalizationManager.GetResource(resourceName);
        }

        public System.Globalization.CultureInfo CurrentContextLanguage
        {
            get
            {
                return innerLocalizationManager.CurrentContextLanguage;
            }
            set
            {
                innerLocalizationManager.CurrentContextLanguage = value;
            }
        }

        public string GetResource(string resourceName, System.Globalization.CultureInfo culture)
        {
            return innerLocalizationManager.GetResource(resourceName, culture);
        }

        #endregion
    }
}
